<!DOCTYPE html>
<html>
<head>
    <title>命名空间实例</title>
</head>
<body>
    <script type="text/javascript">
        var MYAPP = MYAPP || {}
        MYAPP.namespace = function(nt_string){
            var parts = nt_string.split("."),
            parent = MYAPP, i ;
            if(parts[0] === "MYAPP"){
                parts = parts.slice(1);//把数组中的数据项移除数组
            }
            for(i=0;i<parts.length;i+=1){
                if(typeof parent[parts[i] === 'undefined']){
                    parent[parts[i]] = {};
                }
                parent = parent[parts[i]];
            }
            return parent;
        }
        var starTime = new Date().getTime();
        var module2 = MYAPP.namespace('MYAPP.modules.module2');
        module2 === MYAPP.modules.module2;
        var endTime = new Date().getTime();
        console.log("Running time is: " + (endTime-starTime)+' ms');
    </script>
</body>
</html>